package com.mojo.concurrent.concurrent_09_threadlocal;

/**
 * @author <a href="mailto:mojo_jj@163.com">Mojo</a>
 */
public class ThreadLocalDemo1 {
    private static final ThreadLocal<Object> local = new ThreadLocal<>();

    public static void main(String[] args) {
        local.set("muzeh");
        local.set("muzeh1");
        // 只能设置一个变量
        System.out.println("local>>>>>>>>" + local.get());
        local.remove();
        ThreadLocal<Object> local1 = new ThreadLocal<>();
        ThreadLocal<Object> local2 = new ThreadLocal<>();
        local1.set("1111");
        local2.set("2222");
        // 调试查看thread变量，可以看出local1,local2是在同一个ThreadLocalMap类型变量threadLocals对象里面
        Thread thread = Thread.currentThread();
    }
}
